import React from 'react';
import { Card } from 'choerodon-ui';
import { connect } from 'dva';
import Bar from './Bar';
import styles from './style.less';


class YieldAnalysis extends React.Component {

  componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'produceDashboard/fetchAnalysis',
    });
  }

  render() {
    const { analysisData } = this.props.produceDashboard;
    return (
      <Card bordered={false}>
        <div className={styles['yield-analysis']}>
          <div className={styles.title}>
            产量分析
          </div>
        </div>

        <div className={styles['footer-bar']}>
          {
            analysisData.length && (
              <Bar
                height={292}
                data={analysisData}
              />
            )}

        </div>
      </Card>
    );
  }
}


export default connect(
  ({ produceDashboard }) => ({
    produceDashboard,
  })
)(YieldAnalysis);
